home *** CD-ROM | disk | FTP | other *** search
- /*
- * Amiga specific functions
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sys/dir.h>
- #include <sys/stat.h>
- #include <time.h>
- #include <dos/dos.h>
- #include <proto/dos.h>
-
-
- /* maxmium pathlength for AmigaDOS */
-
- #define MAXPATHLEN (255) /* BSTR */
-
- /* UNIX protection bits */
-
- #define S_IRWXU 0000700 /* RWX mask for owner */
- #define S_IRUSR 0000400 /* R for owner */
- #define S_IWUSR 0000200 /* W for owner */
- #define S_IXUSR 0000100 /* X for owner */
-
- #define S_IRWXG 0000070 /* RWX mask for group */
- #define S_IRGRP 0000040 /* R for group */
- #define S_IWGRP 0000020 /* W for group */
- #define S_IXGRP 0000010 /* X for group */
-
- #define S_IRWXO 0000007 /* RWX mask for other */
- #define S_IROTH 0000004 /* R for other */
- #define S_IWOTH 0000002 /* W for other */
- #define S_IXOTH 0000001 /* X for other */
-
- int sas_chmod(const char *filename, int modes)
- {
- unsigned long mask = FIBF_READ | FIBF_WRITE | FIBF_EXECUTE | FIBF_DELETE; /* clear; low-active */
-
- if(modes & S_IRUSR) mask &= ~FIBF_READ;
- if(modes & S_IWUSR) mask &= ~FIBF_WRITE;
- if(modes & S_IXUSR) mask &= ~FIBF_EXECUTE;
- if(modes & S_IWUSR) mask &= ~FIBF_DELETE;
-
- if(modes & S_IRGRP) mask |= FIBF_GRP_READ;
- if(modes & S_IWGRP) mask |= FIBF_GRP_WRITE;
- if(modes & S_IXGRP) mask |= FIBF_GRP_EXECUTE;
- if(modes & S_IWGRP) mask |= FIBF_GRP_DELETE;
-
- if(modes & S_IROTH) mask |= FIBF_OTR_READ;
- if(modes & S_IWOTH) mask |= FIBF_OTR_WRITE;
- if(modes & S_IXOTH) mask |= FIBF_OTR_EXECUTE;
- if(modes & S_IWOTH) mask |= FIBF_OTR_DELETE;
-
- SetProtection((APTR) filename, mask);
-
- return 0; /* returning error would have to mess with errno, too */
- }
-
- int sas_stat(const char *filename, struct stat *st)
- {
- unsigned short mode;
- int result;
-
- result = lstat(filename,st);
-
- mode = st->st_mode & 0xff00; /* mask out file mode bits */
-
- /* convert them to closest UNIX equivalents */
- if (st->st_mode & S_IREAD) mode |= S_IRUSR | S_IRGRP | S_IROTH;
- if (st->st_mode & S_IWRITE) mode |= S_IWUSR | S_IWGRP | S_IWOTH;
- if (st->st_mode & S_IEXECUTE) mode |= S_IXUSR | S_IXGRP | S_IXOTH;
-
- st->st_mode = mode;
-
- return result;
- }
-
- char *getwd(char *buf)
- {
- return(getcwd(buf, MAXPATHLEN));
- }
-
- int readlink(char *path, char *name, int max)
- {
- return(-1);
- }
-
- int symlink(void)
- {
- return(-1);
- }
-
- int utime(void)
- {
- return(0);
- }
-
- int umask(void)
- {
- return(0);
- }
-
- int fork(void)
- {
- return(-1);
- }
-
- int execlp(void)
- {
- return(-1);
- }
-
-
- int findgid(void)
- {
- return(0);
- }
-
- int finduid(void)
- {
- return(0);
- }
-
- int pipe(void)
- {
- return(-1);
- }
-
- int dup(void)
- {
- return(-1);
- }
-
- int setmode(void)
- {
- return(0);
- }
-
- extern int wildmat(char *s, char *p);
-
- int fnmatch (char *pattern, char *string, int flags)
- {
- wildmat(string, pattern);
- }
-
- #include <sys/timeb.h>
-
- void ftime(struct timeb *ftz)
- {
- extern time_t timezone;
-
- (void)time((time_t *) ftz->time);
-
- /* Set the timezone global. */
- tzset();
-
- ftz->timezone = (int) timezone / 60;
- }
-